//讲项目中所有需要发送的http请求都定义在此处
import myReq from './ky'
//用户登录
export const login = (username, password, utype) => {
    //网络请求中间配置对象
    return myReq({
        //请求配置
        url: "user/login",
        method: "post",
        //以默认方式提交请求参数：【application/json】
        headers: {
            "Content-Type": "application/x-www-form-urlencoded"
        },
        data: {
            telphone: username,
            password: password,
            utype: utype
        }
    });
}

//用户注册
export const register = (user) => {
    return myReq({
        url: "user/register",
        method: "post",
        headers: {
            "Content-Type": "application/x-www-form-urlencoded"
        },
        data: user
    })
}
//科目列表
export const subjects = () => {
    return myReq({
        url: "user/subjects",
        method: "get",
    })
}
//每日一句
export const dayWords = () => {
    return myReq({
        url: "user/oneword",
        method: "get",
    })
}
//文件上传功能
export const uploadfile = (params) => {
    return myReq({
        //请求配置
        url: "user/upload",
        method: "post",
        //以默认方式提交请求参数：【application/json】
        headers: {
            "Content-Type": "multipart/form-data"
        },
        data: params
    });
}

//全部文件列表表
export const allsubjects = () => {
    return myReq({
        url: 'user/allsubjects',
        method: 'get'
    })
}

//我的文件列表
export const myfilelist = (uid, query) => {
    let querystring = "user/myfile?uid=" + uid + "&page=" + query.page + "&pageSize=" + query.pageSize;
    return myReq({
        url: querystring,
        method: "get"
    })
}
/* 删除文件 */
export const deleteFile = (id) =>{
    return myReq({
        url: `admin/delFile?id=${id}`,
        method: "get"
    })
}
//科目文件列表
export const subjectfilelist = (sname) => {
    return myReq({
        url: "user/subjectfiles?sname=" + sname,
        method: "get"
    })
}
//院校咨询功能
export const collegewebsites = () =>{
    return myReq({
        url:'/user/collegewebsites',
        method:'get'
    })
}
//用户信息管理（管理员登录后的第一个页面）
export const userInfo = (query) => {
    return myReq({
        url: 'user/list?page=' + query.page + "&pageSize=" + query.pageSize,
        method: 'get'
    })
}
//个人中心（管理者修改用户信息）
export const userCenterInfo = (userinfo) => {
    return myReq({
        url: 'user/doEdit',
        method: 'post',
        data: {
            "operate": "update",
            userinfo
        }
    })
}
//用户主题信息
export const userone = (id) =>{
    return myReq({
        url: 'user/getOne?id='+id,
        method: 'get',
    })
}

/* 管理者添加用户信息 */
export const usercenterAdd = (userinfo) => {
    return myReq({
        url: 'user/doEdit',
        method: 'post',
        data: {
            "operate": "add",
            userinfo
        }
    })
}

/* 管理者删除用户 */
export const userDelete = (id)=>{
    return myReq({
        url: `/user/doDel?id=${id}`,
        method: 'get',
    })
}

/* 全部文件列表 */
export const files = (query)=>{
    return myReq({
        url: "/admin/files?page="+ query.page + "&pageSize=" + query.pageSize,
        method: 'get',
    })
}